package io.renren.modules.utypeone.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.emp.entity.EmployeeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.utypeone.dao.Utype1TableDao;
import io.renren.modules.utypeone.entity.Utype1TableEntity;
import io.renren.modules.utypeone.service.Utype1TableService;


@Service("utype1TableService")
public class Utype1TableServiceImpl extends ServiceImpl<Utype1TableDao, Utype1TableEntity> implements Utype1TableService {

    @Autowired
    Utype1TableDao utype1TableDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key =(String) params.get("key");//模糊查询
        boolean blank = StringUtils.isBlank(key);
        QueryWrapper<Utype1TableEntity> queryWrapper;
        if(blank){
            queryWrapper = new QueryWrapper<Utype1TableEntity>();
        }else {
            queryWrapper = new QueryWrapper<Utype1TableEntity>().like("card_id",key).groupBy("card_id");
        }
        IPage<Utype1TableEntity> page = this.page(
                new Query<Utype1TableEntity>().getPage(params),
                queryWrapper
        );
        return new PageUtils(page);
    }

    @Override
    public void getLabel(String key, Page<Utype1TableEntity> page) {
        utype1TableDao.getLabel(key,page);
    }

    @Override
    public int deleteByLabelId(String cardId) {
        return utype1TableDao.deleteByLabelId(cardId);
    }

//

}